package io.github.wangtianruipopo.cardsdoudizhu.impl;

import io.github.wangtisnruipopo.carscore.types.AbsGame;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

public class DouDiZhuGame extends AbsGame<
        DouDiZhuDecor,
        DouDiZhuCardValue,
        DouDiZhuCard,
        DouDiZhuSuitCards,
        DouDiZhuPlayer,
        DouDiZhuPlayCardsRecord,
        DouDiZhuRound> {

    @Getter
    private List<DouDiZhuCard> landlordCards;

    public static void main(String[] args) {
        System.out.println("开始斗地主游戏");
        DouDiZhuGame game = new DouDiZhuGame();
        // 开始游戏
        game.start();
        System.out.println(game);
    }

    @Override
    public void initPlayers(List<DouDiZhuPlayer> players) {
        // 创建三个玩家
        DouDiZhuPlayer p1 = new DouDiZhuPlayer();
        DouDiZhuPlayer p2 = new DouDiZhuPlayer();
        DouDiZhuPlayer p3 = new DouDiZhuPlayer();
        players.add(p1);
        players.add(p2);
        players.add(p3);
    }

    @Override
    public void beforeDeal() {
        // 游戏正式开始后不再抽取地址牌，虽然此处是废话，但是意思一下，表达可以这么玩
        if (this.isStatus()) return;
        this.landlordCards = new ArrayList<>();
        // 抽取最后三张牌作为地主牌
        for (int i = 0; i < 3; i++) {
            this.landlordCards.add(this.getSuitCards().drawFromBottom());
        }
    }

    @Override
    public void afterDeal() {}
}
